package com.ws.eduservice.controller.front;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ws.commonutils.R;
import com.ws.eduservice.entity.EduCourse;
import com.ws.eduservice.entity.EduTeacher;
import com.ws.eduservice.service.EduTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author ws
 * @create 2024-12-12 20:41
 */
@RestController
@RequestMapping("/eduservice/teacherfront")
@CrossOrigin
public class TeacherFrontController {

    @Autowired
    private EduTeacherService teacherService;

    @GetMapping("{page}/{limit}")
    public R getPageList(@PathVariable Long page,@PathVariable Long limit){
        Page<EduTeacher> pageList = new Page<>(page,limit);
        Map<String,Object> map=teacherService.getPageList(pageList);
        return R.ok().data(map);

    }

    @GetMapping("teacher/{id}")
    public R getById(@PathVariable Long id){
        EduTeacher eduTeacher = teacherService.getById(id);
        List<EduCourse> courseList=teacherService.getCourse(id);
        return R.ok().data("eduTeacher",eduTeacher).data("courseList",courseList);
    }

}
